.TH std::experimental::scope_exit 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::experimental::scope_exit \- std::experimental::scope_exit

.SH Synopsis
   Defined in header <experimental/scope>
   template< class EF >                    (library fundamentals TS v3)
   class scope_exit;

   The class template scope_exit is a general-purpose scope guard intended to call its
   exit function when a scope is exited.

   scope_exit is not CopyConstructible, CopyAssignable or MoveAssignable, however, it
   may be MoveConstructible if EF meets some requirements, which permits wrapping a
   scope_exit into another object.

   A scope_exit may be either active, i.e. calls its exit function on destruction, or
   inactive, i.e. does nothing on destruction. A scope_exit is active after constructed
   from an exit function.

   A scope_exit can become inactive by calling release() on it either manually or
   automatically (by the move constructor). An inactive scope_exit may also be obtained
   by initializing with another inactive scope_exit. Once a scope_exit is inactive, it
   cannot become active again.

   A scope_exit effectively holds an EF and a bool flag indicating if it is active.

.SH Template parameters

   EF                    -                   type of stored exit function
.SH Type requirements
   -
   EF shall be either:
     * a Destructible FunctionObject type,
     * an lvalue reference to FunctionObject,
     * an lvalue reference to function.
   -
   Calling an lvalue of std::remove_reference_t<EF> with no argument shall be
   well-formed.

.SH Member functions

   constructor   constructs a new scope_exit
                 \fI(public member function)\fP
                 calls the exit function when the scope is exited if the scope_exit is
   destructor    active, then destroys the scope_exit
                 \fI(public member function)\fP
   operator=     scope_exit is not assignable
   [deleted]     \fI(public member function)\fP
.SH Modifiers
   release       makes the scope_exit inactive
                 \fI(public member function)\fP

   Deduction guides

.SH Notes

   Constructing a scope_exit of dynamic storage duration might lead to unexpected
   behavior.

   If the EF stored in a scope_exit object refers to a local variable of the function
   where it is defined, e.g., as a lambda capturing the variable by reference, and that
   variable is used as a return operand in that function, that variable might have
   already been returned when the scope_exit's destructor executes, calling the exit
   function. This can lead to surprising behavior.

.SH Example

    This section is incomplete
    Reason: no example

.SH See also

                  wraps a function object and invokes it on exiting the scope through
   scope_fail     an exception
                  \fI(class template)\fP
   scope_success  wraps a function object and invokes it on exiting the scope normally
                  \fI(class template)\fP
   default_delete default deleter for unique_ptr
   \fI(C++11)\fP        \fI(class template)\fP

.SH Category:
     * Todo no example
